package mythesis.gui.main.components.api;
import javafx.scene.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.text.*;
import javafx.scene.image.*;
import javafx.scene.input.*;
import javafx.scene.effect.*;

public class TileSource extends CustomNode
{
    public var text  = "-";
    public var color = 1;
    public var type  = 0;
    public var ban   = false;
    var drop = false; // if drop shadow should be rendered
    
    var descriptionList:String[] = [ "Rolls the dice.",
    								 "Take the shortcut when available",
    								 "Suggests a suspect, a weapon, plus the room you are inside",
    								 "Accuses a suspect, a weapon plus the room you are inside.  False accusations result in a game over."
    								 "Goes to a specified room, given the number of turns.",
    								 "Records a note for future use.  May note a number, a word or a truth.",
    								 "Increases a number you have noted with another number or note.",
    								 "Decreases a number you have noted with another number or note.",
    								 "Multiplies a number you have noted with another number or note.",
    								 "Divides a number you have noted with another number or note.",
    								 "Raises a number to the power of another or note",
    								 "Turns a truth note into true",
    								 "Turns a truth note into false",
    								 "State an if condition",
    								 "State a while condition, limited to 100 iterations",
    								 "Sets a note into an appropriate value" ];
    
    
    var hoverFill:String[]    = ["#558DC6", "#00BB00"];
    var disabledFill:String[] = ["#0D1A26", "#002F00"];
    var defaultFill:String[]  = bind if (ban==false) ["#2E5B89", "#006600"] else disabledFill;
    var curFill:String = if (ban==false) defaultFill[color-1] else disabledFill[color-1];
    
    var bar = Group
    {
        
        content:
        [
        	
        	Rectangle
        	{
        	    
        	    width  : 200
        	    height : 15
				arcWidth  : 10
        	    arcHeight : 10
        	    effect    : bind if (drop==true) DropShadow { offsetY: 4 } else null
        	    fill      : bind if (ban==false) Color.web(defaultFill[color-1]) else Color.web(disabledFill[color-1]);
      		    onMouseEntered: function( e: MouseEvent): Void
       		    				 {
       		    				    if (ban==false){
       		        					curFill = hoverFill[color-1];
       		        					drop = true;
       		        				}
       		    				 }
       		    onMouseExited: function( e: MouseEvent): Void
       		    				 {
       		    				    if (ban==false){
       		        					curFill = defaultFill[color-1];
       		        					drop = false;
       		        				}
       		    				 }
        	}
        ]
    }
    
    var label = Group
    {
        content:
        [
			Text
        	{
        	    x : 29
        	    y : 12
        	    content: text
        	    fill : Color.BLACK;
        	}
        	Text
        	{
        	    x : 30
        	    y : 11
        	    content: text
        	    fill : bind if (ban==false) Color.WHITE else Color.web("#333333");
        	}
        ]
    }
    
    var group = Group
    {
        //translateY: bind if (drop==true) -2 else 0
        translateX: bind if (drop==true) 20 else 0
        content:
        [
        	bar,
        	label
        ]
    }
    
    override public function create():Node
    {
        return group;
    }
}